import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import dataV from '@jiaminghi/data-view'
import { borderBox1 } from '@jiaminghi/data-view'

Vue.use (borderBox1)
Vue.use (dataV)

Vue.use (Vuex)

const state = {
  permissionList: [],
  roleList: [],
  userId: null,
  userName: null,
  userCode: null,
  deptId: null,
  deptName: null,
  currentUser:{}
}

const mutations = {
  SET_CURRENTUSER(state, currentUser) {
    state.currentUser = currentUser
  },
  SET_USER_ID(state, userId) {
    state.userId = userId
  },
  SET_USER_NAME(state, userName) {
    state.userName = userName
  },
  SET_USER_CODE(state, userCode) {
    state.userCode = userCode
  },
  SET_DEPT_ID(state, deptId) {
    state.deptId = deptId
  },
  SET_DEPT_NAME(state, deptName) {
    state.deptName = deptName
  },
  SET_ROLES: (state, roleList) => {
    state.roleList = roleList
  },
  SET_PERMISSIONS: (state, permissionList) => {
    state.permissionList = permissionList
  }

}

const store = new Vuex.Store ({
  modules: {
    app,
    settings,
    user
  },
  getters,
  state,
  mutations
})

export default store
